package nsu.grandfinal;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class CustomListAdapter extends ArrayAdapter<XmlData> {
	private ArrayList<XmlData>	items;
	View												v;
	
	public CustomListAdapter(Context context, int textViewResourceId, ArrayList<XmlData> items) {
		super(context, textViewResourceId, items);
		this.items = items;
	}
	
	public View getView(int position, View convertView, ViewGroup parent) {
		v = convertView;
		if (v == null) {
			LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			v = vi.inflate(R.layout.searchlayout2, null);
		}
		int Last = this.getCount();
		if ((Last - 1) == position) {
			// getNewList(Data);
			TextView tv1 = (TextView) v.findViewById(R.id.dataItem01);
			TextView tv2 = (TextView) v.findViewById(R.id.dataItem02);
			TextView tv3 = (TextView) v.findViewById(R.id.dataItem03);
			tv1.setText("10개 더보기");
			tv2.setText("");
			tv3.setText("");
		} else {
			XmlData xmlData = (XmlData) items.get(position);
			if (xmlData != null) {
				TextView tv1 = (TextView) v.findViewById(R.id.dataItem01);
				TextView tv2 = (TextView) v.findViewById(R.id.dataItem02);
				TextView tv3 = (TextView) v.findViewById(R.id.dataItem03);
				tv1.setText("이름 : " + xmlData.d_title);
				tv2.setText("전화번호 : " + xmlData.d_phone);
				tv3.setText("주소 : " + xmlData.d_address);
			}
		}
		return v;
	}
}